﻿using LoginUI.UI;
using UnityEngine;
using UnityEngine.UI;

namespace Login.Server
{
    public class ServerLeftItem : MonoBehaviour
    {
        public Text ButtonText;
        public Button buttonSelf;
        private int endIndex;
        private int startIndex;

        public void InitButtonText(int[] rangeStrings)
        {
            startIndex = rangeStrings[0];
            endIndex = rangeStrings[1];
            var buttonText = startIndex + "~" + endIndex + "区";
            ButtonText.text = buttonText;
        }

        private void Start()
        {
            buttonSelf.onClick.AddListener(() =>
            {
                var panel = UIManager.Instance.GetPanel<ChooseServerPanel>();
                panel.UpdatePanel(startIndex, endIndex);
            });
        }
    }
}